package com.example.controller;

import com.example.pojo.sandbox.ExecuteCodeRequest;
import com.example.pojo.sandbox.ExecuteCodeResponse;
import com.example.service.SandboxService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "沙箱测试")
@RestController("/Sandbox")
public class SandboxController {

    @Autowired
    private SandboxService sandboxService;

    @Operation(summary = "手动输入测试数据测试代码沙箱")
    @PostMapping("/ExecuteCode")
    public ExecuteCodeResponse SandboxExecuteCode(@RequestBody ExecuteCodeRequest executeCodeRequest) {
        // 调用方法对代码进行编译执行
        return sandboxService.compileAndRunCode(executeCodeRequest);
    }

}
